<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateChatCustomerServiceTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('chat_customer_service', ['comment' => 'chat客服', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('name', 'string', ['limit'  =>  60, 'null' => true, 'default' => null, 'comment' => '客服昵称'])
            ->addColumn('avatar', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '客服头像'])
            ->addColumn('room_id', 'string', ['limit' => 60, 'default' => 'admin', 'comment' => '客服房间'])
            ->addColumn('max_num', 'integer', ['limit'  =>  10, 'default' => 10, 'comment' => '最大接待人数'])
            ->addColumn('last_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '上次服务时间'])
            ->addColumn(Column::enum('status', ['offline', 'online', 'busy'])->setDefault('offline')->setComment('状态'))
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('chat_customer_service');
        $table->drop();
    }
}
